package com.scuec.tourismwebsite.mapper;



import com.scuec.tourismwebsite.entity.WeatherTip;
import com.scuec.tourismwebsite.vo.ViewWeatherTip;
import org.apache.ibatis.annotations.*;

import java.util.List;
//
@Mapper
public interface WeatherTipMapper {
    @Select("select wt.tip_id, c.city_id, c.city_name, c.province, wt.forecast_date, wt.sports_index, wt.sports_advice, wt.clothing_index, wt.clothing_advice, wt.tourism_index, wt.tourism_advice, wt.traffic_index, wt.traffic_advice, wt.comfort_index, wt.comfort_advice \n" +
            "from weather_tip wt \n" +
            "join city c on wt.city_id = c.city_id \n" +
            "group by wt.tip_id, c.city_id, wt.forecast_date, wt.sports_index, wt.sports_advice, wt.clothing_index, wt.clothing_advice, wt.tourism_index, wt.tourism_advice, wt.traffic_index, wt.traffic_advice, wt.comfort_index, wt.comfort_advice \n" +
            "order by c.city_id ASC, wt.forecast_date ASC")
    List<ViewWeatherTip> findWeatherTip();
    @Insert("insert into weather_tip (city_id, sports_index, sports_advice, " +
            "clothing_index, clothing_advice, tourism_index, tourism_advice, traffic_index, " +
            "traffic_advice, comfort_index, comfort_advice, forecast_date)" +
            "values (#{city_id}, #{sports_index}, #{sports_advice}, #{clothing_index}," +
            "        #{clothing_advice}, #{tourism_index}, #{tourism_advice},#{traffic_index}," +
            "        #{traffic_advice}, #{comfort_index},  #{comfort_advice},#{forecast_date})")
    Integer insertWeatherTip(WeatherTip weatherTip);


    @Update("update weather_tip set city_id = #{city_id}, forecast_date = #{forecast_date}," +
            " sports_index = #{sports_index}," +
            "sports_advice = #{sports_advice}," +
            "clothing_index = #{clothing_index}," +
            "clothing_advice = #{clothing_advice}," +
            "tourism_index = #{tourism_index}," +
            "tourism_advice = #{tourism_advice}," +
            "traffic_index = #{traffic_index}," +
            "traffic_advice = #{traffic_advice}," +
            "comfort_index = #{comfort_index}," +
            "comfort_advice = #{comfort_advice} " +
            "where tip_id= #{tip_id}")
    Integer updateWeatherTip(WeatherTip weatherTip);


    @Delete("delete from weather_tip where tip_id = #{tip_id}")
    Integer deleteWeatherTip(Integer tip_id);
}

